#ifndef ABSTRACTSECURITYCONTEXTHANDLER_H
#define ABSTRACTSECURITYCONTEXTHANDLER_H

#include <map>
using namespace std;

#include <plugin/plugin_global.h>

#include <plugin/util/AbstractSecurityContext.h>

namespace antu
{
namespace plugin
{
class PLUGINSHARED_EXPORT AbstractSecurityContextHandler
{
public:
    AbstractSecurityContextHandler();
    virtual ~AbstractSecurityContextHandler();

    virtual void initFromContent(const char* p, size_t length) = 0;
    virtual void initFromFile(const QString& fileName);

    virtual bool isAllowed(const QString& moduleCode) const;
    virtual bool isAllowed(const QString& moduleCode, const QString& unit) const;

protected:
    map<QString, AbstractSecurityContextSharedPtr> m_oSecurityContexts;
};

class PLUGINSHARED_EXPORT NullSecurityContextHandler : public AbstractSecurityContextHandler
{
public:
    NullSecurityContextHandler();
    virtual ~NullSecurityContextHandler();

    virtual void initFromContent(const char* p, size_t length);
    virtual bool isAllowed(const QString& moduleCode) const;
    virtual bool isAllowed(const QString& moduleCode, const QString& unit) const;
};

}
}

#endif // ABSTRACTSECURITYCONTEXTHANDLER_H
